/**
 * Desenvolvido pela Fábrica de Software do CESUPA.
 * Todos os direitos reservados.
 */
package br.cesupa.fabsoft.nomedoprojeto.modules.systemmodule.beans;

import br.cesupa.fabsoft.nomedoprojeto.utils.ManagedBeanUtils;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Breno Leite
 */
public class SessionBean {

    private String searchQuery;

    public SessionBean() {
    }

    public static SessionBean getCurrentInstance() {
        return (SessionBean) ManagedBeanUtils.getManagedBeanCurrentInstance("SessionBean");
    }

    /**
     * Finish the current session, destroying all non-persisted data related to
     * it.
     *
     * @return
     */
    public String logout() {
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().
                getExternalContext().getSession(false);
        session.invalidate();
        return "SYSTEM.goToInitialPage";
    }

    /**
     * @return the searchQuery
     */
    public String getSearchQuery() {
        return searchQuery;
    }

    /**
     * @param searchQuery the searchQuery to set
     */
    public void setSearchQuery(String searchQuery) {
        this.searchQuery = searchQuery;
    }
}
